{include file="../application/admin/view/header.html"}
<link rel="stylesheet" type="text/css" href="/static/css/uploadify.css">
</head>
<body>
<div class="container">
	<div class="col-md-12">
		<div class="alert kesn_prompt"></div>
	</div>
<div class="row">
	<form class="form-inline">
	  <div class="form-group">
	    <label for="resource_id">ID</label>
	    <input type="text" class="form-control" id="resource_id" placeholder="" disabled="disabled" value="{$resource.id}">
	  </div>
	  <div class="form-group">
	    <label for="resource_name">资料名</label>
	    <input type="text" class="form-control" id="resource_name" placeholder="" value="{$resource.resource}">
	  </div>
	   <div class="form-group">
	    <label for="resource_path">原文件</label>
	    <input type="text" class="form-control" id="resource_path" placeholder="" value="{$resource.path}" disabled="disabled">
	  </div>
	  </form>
	  <br />
	  <br />
	  <div id="fileQueue"></div>
	  <input type="file" name="resource_file" id="uploadify" multiple="true"/>
			<p>
				<button type="button" class="btn btn-primary" id="uploadStart">上传</button>
				<button type="button" class="btn btn-warning" id="uploadCancle">取消上传</button>
			</p>
	
</div>
</div>


{include file="../application/admin/view/footer.html"}
<script type="text/javascript" src="/static/js/jquery.uploadify.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$('#uploadStart').click(function(){
		$('#uploadify').uploadify('upload','*');
	});
	$('#uploadCancle').click(function(){
		$('#uploadify').uploadify('cancel');
	});
    $("#uploadify").uploadify({
    	'buttonText':'选择上传资料',
    	'swf'     : '/static/swf/uploadify.swf',
        'uploader': 'upload_file',
        'fileObjName' : 'resource_file',
        'cancelImg': '/static/img/uploadify-cancel.png',
        'queueID': 'fileQueue',
        'auto': false,
        'multi': true,
        'method' : 'get', 
        'removeCompleted' : true,
        'onUploadStart' : function(file) {
        	var resource_name = $('input#resource_name').val();
        	var resource_id = $('input#resource_id').val();
        	resource_name = encodeURI(resource_name);
            $("#uploadify").uploadify("settings", "formData", {
            	resource_name:resource_name,
            	resource_id:resource_id});
        },
           'onUploadSuccess' :function(file,data,res){
         	data = JSON.parse(data);
         	if (data.err != '0') {
         		kesn_prompt('fail',data.content);
         	}else{
         		$("#create_resource").modal('hide');
         		kesn_prompt('success',data.content);
         	}
         }

    });
}); 
</script>
</footer>
</body>
</html>